<template>
    <!-- 页面 -->
    <el-menu-item v-if="item.type == '2'" :id="item.id" :index="item.perm" @click="changeRouter(item)">
        <el-icon v-if="item.icon">
            <component :is="item.icon"></component>
        </el-icon>
        <span>{{ item.name }}</span>
    </el-menu-item>
    <!-- 目录 -->
    <el-sub-menu v-if="item.type == '1'" :id="item.id" :index="item.id+''">
        <template #title>
            <el-icon v-if="item.icon">
                <component :is="item.icon"></component>
            </el-icon>
            <span>{{ item.name }}</span>
        </template>
        <LeftMenu :item="child" v-for="child in item.children" :key="child.id"></LeftMenu>
    </el-sub-menu>
</template >
<script setup>
import { useRouter } from 'vue-router'
const router = useRouter();
const props = defineProps({
    item: Object
})
const changeRouter = (item) => {
    router.push(item.perm);
}
</script>
